package com.woniuxy02;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 作者
 * @create 2025-09-08 14:26
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Student implements Comparable{
    private int id;
    private String name;
    private int age;


    @Override
    public int compareTo(Object o) {
//        if(o instanceof Student){
//            Student that = (Student)o;
//            //按照年龄升序排列
//            return this.age - that.age;
//            //按照年龄降序排列
////            return that.age - this.age;
//        }
        if(o instanceof Student that){
            return this.age - that.age;
        }
        return 0;
    }
}
